package com.hl.sfzy.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.SysCourseEvaluate;
import com.hl.sfzy.entity.SysCourseVideos;
import com.hl.sfzy.mapper.SysCourseEvaluateMapper;
import com.hl.sfzy.service.SysCourseEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: sfzy
 * @ClassName SysCourseEvaluateServiceImpl
 * @description:
 * @author: lyp
 * @create: 2024-07-12 18:00
 * @Version 1.0
 **/
@Service("sysCourseEvaluateService")
public class SysCourseEvaluateServiceImpl implements SysCourseEvaluateService {
    @Autowired
    private SysCourseEvaluateMapper sysCourseEvaluateMapper;

    @Override
    public int add(SysCourseEvaluate entity) {
        return sysCourseEvaluateMapper.insert(entity);
    }

    @Override
    public int edit(SysCourseEvaluate entity) {
        return sysCourseEvaluateMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return sysCourseEvaluateMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return sysCourseEvaluateMapper.deleteBatch(ids);
    }

    @Override
    public List<SysCourseEvaluate> find(SysCourseEvaluate entity) {
        return sysCourseEvaluateMapper.select(entity);
    }

    @Override
    public SysCourseEvaluate findById(Integer id) {
        return sysCourseEvaluateMapper.selectById(id);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, SysCourseEvaluate entity) {//开启分页
        PageHelper.startPage(pageNum, pageSize);
        //当前页数据
        List<SysCourseEvaluate> list = sysCourseEvaluateMapper.select(entity);
        //分页信息对象
        PageInfo<SysCourseEvaluate> pageInfo = new PageInfo<>(list);

        Map<String, Object> map = new HashMap<>();

        //map存储当前页数据、总页数、总记录数
        map.put(CommonConstant.PAGE_LIST,list);
        map.put(CommonConstant.PAGE_TOTAL,pageInfo.getPages());
        map.put(CommonConstant.TOTAL,pageInfo.getTotal());
        return map;
    }
}

